from ultralytics.data.dataset import YOLODataset
from ultralytics.cfg import cfg2dict
import cv2

cocoyaml = './coco8/coco8.yaml'
cfg = cfg2dict(cocoyaml)
imgpath = './coco8/images'

yolodataset = YOLODataset(imgpath, data=cfg, task='detect', augment=False)
print(yolodataset.augment, yolodataset.transforms.__repr__())

labels = yolodataset.get_image_and_label(1)
img = labels['img']

trans_img = yolodataset.transforms(labels)['img'].permute(1,2,0).numpy()
savedir = './trans_img.jpg'
cv2.imwrite(savedir, trans_img)

